/*******************************************************************************
 * Copyright (c) 2010 L.Carbonnaux.
 *******************************************************************************/
package org.lcx.taskvision.ui;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.mylyn.tasks.core.AbstractTaskListMigrator;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.lcx.taskvision.core.TaskVisionCorePlugin;
import org.lcx.taskvision.core.attribute.TaskVisionAttribute;
import org.w3c.dom.Element;

/**
 * @author Laurent Carbonnaux
 */
public class TaskVisionTaskListMigrator extends AbstractTaskListMigrator {

	private static final String KEY_SCRUMVISION = "ScrumVision";

	private static final String KEY_SCRUMVISION_TASK = KEY_SCRUMVISION + "Task";

	private static final String KEY_SCRUMVISION_QUERY = KEY_SCRUMVISION + "Query";
	
	@Override
	public String getConnectorKind() {
		return TaskVisionCorePlugin.CONNECTOR_KIND;
	}

	@Override
	public Set<String> getQueryElementNames() {
		Set<String> names = new HashSet<String>();
		names.add(KEY_SCRUMVISION_QUERY);
		return names;
	}

	@Override
	public String getTaskElementName() {
		return KEY_SCRUMVISION_TASK;
	}

	@Override
	public void migrateQuery(IRepositoryQuery query, Element element) {
		// nothing to do
	}

	@Override
	public void migrateTask(ITask task, Element element) {
		task.setAttribute(TaskVisionAttribute.COMPLETED.getSvKey(), element.getAttribute(TaskVisionAttribute.COMPLETED.getSvKey()));		
		task.setTaskKey(element.getAttribute(TaskVisionAttribute.TASKID.getSvKey()));
	}

}
